import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/app_bar.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_rank_header.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_rank_list.dart';
import 'package:flutter_eve_plugin/constants/plot_trigger.dart';
import 'package:flutter_eve_plugin/pages/main/actions.dart';
import 'package:flutter_eve_plugin/pages/ye_xiu/checkpoint/actions.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class CheckpointRankPage extends StatefulWidget {
  final String title;

  CheckpointRankPage({Key key, this.title}) : super(key: key);

  _CheckpointRankPageState createState() => _CheckpointRankPageState();
}

class _CheckpointRankPageState extends State<CheckpointRankPage> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(onInit: (store) {
      ///发现一个新的副本
     store.dispatch(doTriggerPlot(PlotTrigger.plotTriggerType1,
          store.state.yeXiuState.checkpointState.dungeonid));
      store.dispatch(
          stages(store.state.yeXiuState.checkpointState.dungeonid, context));
    }, converter: (store) {
      return AppStateViewModel(state: store.state);
    }, builder: (context, vm) {

      var dungeonVitality = vm.state.yeXiuState.checkpointState.dungeonVitality;
      return Container(
        decoration: BoxDecoration(
            image: DecorationImage(
                image: AssetImage(
                    imageUtilYeXiu('checkpoint/icon_checkpoint_bg@3x')),
                fit: BoxFit.fitWidth,
                alignment: Alignment.topCenter)),
        child: SafeArea(
          child: Scaffold(
            backgroundColor: Colors.transparent,
            appBar: buildMainAppBar(dungeonVitality?.currVitality ?? 0,
                dungeonVitality?.totalVitality ?? 0),
            body: SingleChildScrollView(
              child: Column(
                children: <Widget>[
                  CheckpointRankHeaderWidget(),
                  SizedBox(
                    height: setRatio(42),
                  ),
                  CheckpointRankListWidget(),
                ],
              ),
            ),
          ),
        ),
      );
    });
  }
}
